package pl.register.android;

import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.ProgressBar;
import android.widget.TextView;
import pl.register.android.widget.FakeProgressThread;
import roboguice.activity.RoboSplashActivity;

import static pl.register.android.util.VersionUtil.getVersionName;

/**
 * @author Mateusz Strzelecki
 * @since 2013-09-17
 */
public class SplashActivity extends RoboSplashActivity{

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.splash);
        ProgressBar progressBar = (ProgressBar) findViewById(R.id.activity_splash_progress_bar);
        new FakeProgressThread(progressBar).execute();
        populateVersionName();
    }

    private void populateVersionName() {
        TextView viewById = (TextView) findViewById(R.id.app_version_name);
        viewById.setText(getVersionName(this, "undefined"));
    }

    @Override
    protected void startNextActivity() {
        startActivity(new Intent(this, HomeActivity.class));
    }

}
